<script setup>
import HelloWorld from './components/HelloWorld.vue'
</script>

<template>
  <div>
    <a href="https://vite.dev" target="_blank">
      <img src="/vite.svg" class="logo" alt="Vite logo" />
    </a>
    <a href="https://vuejs.org/" target="_blank">
      <img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
    </a>
  </div>
  <HelloWorld msg="Vite + Vue" />
</template>

<style scoped>
.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
  transition: filter 300ms;
}

.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}

.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
<script>
import wx from 'weixin-js-sdk'
export default {
  name: 'App',
  components: {
    HelloWorld
  },
  methods: {
    getWechatConfig() {
      let url = window.location.href.split('#')[0]
      console.log(url)
      let data =  {
    "signature": "98549aaef3f358e6a0b4d84ceaaa7362f8ceaa94",
    "appId": "wxc289b815b2f4286d",
    "jsapi_ticket": "xN-5lpdNhLiE7IEBU_UcHnjhjax8-U5QuEYqprpzJjCTym1quidkPyk1IplVKk9icy9krmNxxhJSG1iSwZTSxg",
    "url": "http://localhost:5173/",
    "nonceStr": "fc4fb071-cf2e-4bbe-a6d6-8db754c521bf",
    "timestamp": "1750734343"
  }
      wx.config({
        debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: data.appId, // 必填，公众号的唯一标识
        timestamp: data.timestamp, // 必填，生成签名的时间戳
        nonceStr: data.nonceStr, // 必填，生成签名的随机串
        signature: data.signature,// 必填，签名
        jsApiList: [
          'updateAppMessageShareData',
          'updateTimelineShareData'
        ]  // 必填，需要使用的JS接口列表,
      })
      // 通过error接口处理失败验证
      // wx.error(function (errres) {
      //   console.info("失败：", errres);
      // });

      wx.ready(() => {
        let shareInfo = {
          title: '分享标题',
          desc: '分享描述',
          link: '分享链接',
          imgUrl: '分享图片'
        }

        // wx.onMenuShareTimeLine(shareInfo)
        wx.onMenuShareAppMessage(shareInfo)
        wx.onMenuShareQQ(shareInfo)
        wx.onMenuShareWeibo(shareInfo)
        wx.onMenuShareQZone(shareInfo)

        wx.updateAppMessageShareData(shareInfo)
        wx.updateTimelineShareData(shareInfo)
        console.log('微信配置已就绪')
      })
    },
  },
  mounted() {
    this.getWechatConfig()
  }
}
</script>
